/**
 * English Volume Unit Tests
 * Tests convert and toUnit for each Unit Type
 */

package cmsc495.mach2.test.unit.english;

import cmsc495.mach2.unit.english.EnglishVolumeUnit;
import junit.framework.TestCase;

/**
 * @author Michael Swann
 */
public class EnglishVolumeUnitValidation extends TestCase {

	// Amount of Error Allowed
	private static final double					DELTA				= 0.01;

	private static final double					CUBICINCHES_VALUE	= 46655.9999795711;
	private static final double					CUBICFEET_VALUE		= 27.0;
	private static final double					CUBICYARDS_VALUE	= 1.0;
	private static final double					CUBICMETERS_VALUE	= 0.7645548575;

	private static final double					values[]			= { CUBICINCHES_VALUE, CUBICFEET_VALUE, CUBICYARDS_VALUE, CUBICMETERS_VALUE };
	private static final EnglishVolumeUnit[]	englishVolumeUnits	= EnglishVolumeUnit.values();

	public EnglishVolumeUnitValidation() {
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishVolumeUnit#convert(double, mach2convert.englishunit.EnglishVolumeUnit)}
	 * .
	 */
	public final void testConvert() {
		for (int i = 0; i < englishVolumeUnits.length; i++) {
			for (int j = 0; j < englishVolumeUnits.length; j++) {
				double result = englishVolumeUnits[i].convert(values[j], englishVolumeUnits[j]);
				System.out.println("ASSERT: " + values[i] + " = " + result + " " + englishVolumeUnits[i] + ".convert(" + values[j] + ", " + englishVolumeUnits[j] + "))");
				assertEquals(values[i], result, DELTA);
			}
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishVolumeUnit#toCubicInches(double)}.
	 */
	public final void testToCubicInches() {
		for (int i = 0; i < englishVolumeUnits.length; i++) {
			double result = englishVolumeUnits[i].toCubicInches(values[i]);
			System.out.println("ASSERT: " + CUBICINCHES_VALUE + " = " + result + " " + englishVolumeUnits[i] + ".toCubicInches(" + values[i] + ") ");
			assertEquals(CUBICINCHES_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishVolumeUnit#toCubicFeet(double)}.
	 */
	public final void testToCubicFeet() {
		for (int i = 0; i < englishVolumeUnits.length; i++) {
			double result = englishVolumeUnits[i].toCubicFeet(values[i]);
			System.out.println("ASSERT: " + CUBICFEET_VALUE + " = " + result + " " + englishVolumeUnits[i] + ".toCubicFeet(" + values[i] + ") ");
			assertEquals(CUBICFEET_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishVolumeUnit#toCubicYards(double)}.
	 */
	public final void testToCubicYards() {
		for (int i = 0; i < englishVolumeUnits.length; i++) {
			double result = englishVolumeUnits[i].toCubicYards(values[i]);
			System.out.println("ASSERT: " + CUBICYARDS_VALUE + " = " + result + " " + englishVolumeUnits[i] + ".toCubicYards(" + values[i] + ") ");
			assertEquals(CUBICYARDS_VALUE, result, DELTA);
		}
	}

	/**
	 * Test method for
	 * {@link mach2convert.englishunit.EnglishVolumeUnit#toCubicMeters(double)}.
	 */
	public final void testToCubicMeters() {
		for (int i = 0; i < englishVolumeUnits.length; i++) {
			double result = englishVolumeUnits[i].toCubicMeters(values[i]);
			System.out.println("ASSERT: " + CUBICMETERS_VALUE + " = " + result + " " + englishVolumeUnits[i] + ".toCubicMeters(" + values[i] + ") ");
			assertEquals(CUBICMETERS_VALUE, result, DELTA);
		}
	}
}